﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Collections.Specialized;

namespace FuturamaKassa.Database {
    class DataService {

        private readonly string url = "data.manuras.com";

        private WebClient webClient;
        private NameValueCollection postVars;

        public DataService() {
            webClient = new WebClient();
            postVars = new NameValueCollection();
        }

        public void getTags(List<string> tagsList) {
            postVars.Add("command", "getTags");

            string tags = String.Join(";", tagsList.ToArray());

            postVars.Add("ids", tags);
            
            string xmlString = sendRequest();

            Console.WriteLine("Gotten back: " + xmlString);
        }

        private string sendRequest() {
            byte[] responseArray = webClient.UploadValues(url,"POST",postVars);

            postVars.Clear();
            return Encoding.ASCII.GetString(responseArray);
        }
    }
}
